package com.example.shiroplusdemo.entity;

import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * @author ：Anitaxiaofeng
 * @description：
 * @create 2018-01-12
 **/
@Data
public class CustomPage<T> {

    //当前页数
    private int page;

    //每页显示数量
    private int pagesize;

    //总条数
    private long records;

    //数据列表
    private List<T> rows;

    //总页数
    private int total;

    //排序字段
    private String orderByField;

    //是否升序
    private boolean isAsc;

    public CustomPage(Page<T> page,FrontPage frontPage){
        this.page = page.getNumber();//返回当前页
        this.pagesize = page.getSize();
        this.records = page.getTotalElements();
        this.rows = page.getContent();
        this.total = page.getTotalPages();
        this.orderByField = frontPage.getSidx();
        this.isAsc = true;
    }
}